class Solution {
    List<List<Integer>> ret;
    List<Integer> path;
    public List<List<Integer>> subsets(int[] nums) {
        ret = new ArrayList<>();
        path = new ArrayList<>();
        dfs(nums, 0);
        return ret;
    }
    public void dfs(int[] nums, int pos) {
        //函数出口
        if(pos == nums.length) {
            ret.add(new ArrayList<>(path));
            return;
        }
        
        //选
        path.add(nums[pos]);
        dfs(nums, pos + 1);
        //回溯 -> 恢复现场
        path.remove(path.size() - 1);

        //不选(不做任何操作即可)
        dfs(nums, pos + 1);
    }
}